package com.example.Android_test.util;

/**
 * Created with IntelliJ IDEA.
 * User: anpi0413
 * Date: 05.06.13
 * Time: 13:33
 * To change this template use File | Settings | File Templates.
 */
public class Test {
     public static void main (String args[]) {
         /*System.out.println(UniqViewIDHelper.INSTANCE.getUniqueId());
         System.out.println(UniqViewIDHelper.INSTANCE.getUniqueId());
         System.out.println(UniqViewIDHelper.INSTANCE.getUniqueId());
         System.out.println(UniqViewIDHelper.INSTANCE.getUniqueId());
         System.out.println(UniqViewIDHelper.INSTANCE.getUniqueId());
*/

         //System.out.println(getMessageForResult(10, 5));
         String str = "<![CDATA[<b>White</b> is the color of snow, clouds, milk and it is associated with winter.]]>";
         System.out.println(replaceTagBWithStars(str));
     }

    public static String getMessageForResult(int goodCount, int badCount) {
        double result = (double) goodCount/(goodCount+badCount);
        System.out.println(result);
        if (result >= 0.8) {
            return "excellent";
        }
        if (result >= 0.5) {
            return "good";
        }

        return "bad";
    }

    private static String replaceTagBWithStars(String str) {
        String result = "";
        while (str.contains("<b>")) {
            result += str.substring(0, str.indexOf("<b>") + "<b>".length());
            str = str.substring(str.indexOf("<b>") + "<b>".length());

            result += "***";

            result += str.substring(str.indexOf("</b>"));
            str = str.substring(str.indexOf("</b>"));
        }

        return result;
    }
}
